*Court Curbing Lower State Courts in the US
*SPPQ Replication File
*Data and code in Stata 18.5

*Source Data: New Data on Court Curbing by State Legilstaures
*https://dataverse.unc.edu/dataset.xhtml?persistentId=doi:10.15139/S3/MJMNUG 

*use/New Data on Court Curbing SPPQ.dta
generate trialcourt= 1 if court_affected== 3 | court_affected==4 | court_affected==7 
replace trialcourt=0 if trialcourt==.
generate IAC=1 if court_affected==2 | court_affected==6 
replace IAC=0 if IAC==.
generate SSC=1 if court_affected==1
replace SSC=0 if SSC==. 

***The following commands produce the results in Table 2: Descrptive Statistics
*Column 1: 
tab trialcourt 
tab type_code trialcourt
display (39/190)*100
tab sponsorparty trialcourt
display (95/151)*100
tab memberofjudiciarycommittee trialcourt
display (59/155)*100
tab memberofleadership trialcourt
display (22/156)*100

*Column 2:
tab IAC 
tab type_code IAC
display (76/106)*100
tab sponsorparty IAC
display (71/95)*100
tab memberofjudiciarycommittee IAC
display (48/95)*100
tab memberofleadership IAC
display (22/95)*100

*Coulumn 3: 
tab SSC 
tab type_code SSC
display (78/206)*100
tab sponsorparty SSC
display (138/186)*100
tab memberofjudiciarycommittee SSC
display (66/187)*100
tab memberofleadership SSC
display (19/187)*100
clear 

*Data
*Bill-level data (Tables 3-4 and Figure 1)
*use/LCC_billlevel.dta

*State-level data (Table 5): 
*use/Lower Court Curbing.dta

*Install additional stata packages
 ssc install relogit 
 ssc install margin


***The following commands produce the results in Table 3: Multinominal Logit: Introduction fo court-curbing bill attacking court level***
*use/LCC_billlevel.dta
xtmlogit court_affect_categorical sponsor_lower_distance sponsor_court_distance memberofjudiciarycommittee sponsorparty trial_contestable trial_merit leg_prof uh_perc_d, i(state_fips) re base(0)



*The following commands produce the results in Figure 1: Legislative professionalism and the probability a bill will attack each court type
*use/LCC_billlevel.dta
xtmlogit court_affect_categorical sponsor_lower_distance sponsor_court_distance memberofjudiciarycommittee sponsorparty trial_contestable trial_merit leg_prof uh_perc_d, i(state_fips) re base(0)
margins, at (leg_prof= (0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1))
marginsplot


***The following commands produce the results in Table 4: Bill-level trial court analysis***
*use/LCC_billlevel.dta
xtlogit trialcourt newid memberofjudiciarycommittee sponsorparty trial_contestable trial_merit leg_prof uh_perc_d, i(state_fips) re 
clear


***The following commands produce the results in Table 5: State-year models of the count and presences of court-curbing legislation***
*use/Lower Court Curbing.dta
*Model 1: Random effects ordinal logit trial court count of cc bill in state year
xtologit trial_ordinal lower_leg_distance rep_cont_one trial_contestable trial_merit leg_prof uh_perc_d, i(fipstate)

*Model 2: Random effects logit model trial court presence of cc bill in state year
xtlogit trial_dummy lower_leg_distance rep_cont_one trial_contestable trial_merit leg_prof uh_perc_d,i(state_fips) re
margins, at (leg_prof= (0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1))
margins, at (rep_cont_one=(0 1))


*Model 3: Random effcts ordinal logit
xtologit iac_ordinal lower_leg_distance rep_cont_one trial_contestable trial_merit leg_prof uh_perc_d, i(state_fips)


*Model 4: Random effects logit model IAC presence of cc bill in state year
xtlogit IAC_dummy lower_leg_distance rep_cont_one trial_contestable trial_merit leg_prof uh_perc_d,i(state_fips) re

